import 'package:childrenapp/buy.dart';
import 'package:childrenapp/favorite.dart';
import 'package:childrenapp/home.dart';
import 'package:childrenapp/me.dart';
import 'package:flutter/material.dart';

class Home_Page extends StatefulWidget {
  const Home_Page({super.key});

  @override
  State<Home_Page> createState() => _Home_PageState();
}

class _Home_PageState extends State<Home_Page> {
  int _currentIndex = 0;
  List pages = [Home(), Favorite(), Buy(), Me()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: pages[_currentIndex],
      bottomNavigationBar: Container(
        height: 120,
        decoration: const BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.vertical(
              top: Radius.circular(30),
            ),
            boxShadow: [
              BoxShadow(
                  color: Colors.grey, blurRadius: 4, offset: Offset(0, 0)),
            ]
            // color: Colors.blue,
            ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: [
            GestureDetector(
              onTap: () {
                setState(() {
                  _currentIndex = 0;
                });
              },
              child: Container(
                padding: EdgeInsets.symmetric(horizontal: 10),
                height: 120,
                child: Row(
                  children: [
                    Image(
                      image: AssetImage('images/Icon/Home.png'),
                      width: 30,
                      height: 30,
                    ),
                    SizedBox(
                      width: 5,
                    ),
                    Text(
                      _currentIndex == 0 ? 'Home' : '',
                      style: TextStyle(
                        fontSize: 20,
                      ),
                    ),
                  ],
                ),
              ),
            ),
            GestureDetector(
              onTap: () {
                setState(() {
                  _currentIndex = 1;
                });
              },
              child: Container(
                padding: EdgeInsets.symmetric(horizontal: 10),
                height: 120,
                child: Row(
                  children: [
                    Image(
                      image: AssetImage(_currentIndex == 1
                          ? 'images/Icon/Heart.png'
                          : 'images/Icon/Heart（3）.png'),
                      width: 30,
                      height: 30,
                    ),
                    SizedBox(
                      width: 5,
                    ),
                    Text(
                      _currentIndex == 1 ? 'Favoride' : '',
                      style: TextStyle(
                        fontSize: 20,
                      ),
                    ),
                  ],
                ),
              ),
            ),
            GestureDetector(
              onTap: () {
                Navigator.push(context, MaterialPageRoute(builder: (context) {
                  return Buy();
                }));
              },
              child: Container(
                padding: EdgeInsets.symmetric(horizontal: 10),
                height: 120,
                child: Row(
                  children: [
                    Image(
                      image: AssetImage('images/Icon/Buy.png'),
                      width: 30,
                      height: 30,
                    ),
                    SizedBox(
                      width: 5,
                    ),
                  ],
                ),
              ),
            ),
            GestureDetector(
              onTap: () {
                setState(() {
                  _currentIndex = 3;
                });
              },
              child: Container(
                padding: EdgeInsets.symmetric(horizontal: 10),
                height: 120,
                child: Row(
                  children: [
                    Image(
                      image: AssetImage('images/Icon/Profile.png'),
                      width: 30,
                      height: 30,
                    ),
                    SizedBox(
                      width: 5,
                    ),
                    Text(
                      _currentIndex == 3 ? 'Me' : '',
                      style: TextStyle(
                        fontSize: 20,
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
